//
//  MyViewController.m
//  PlayDAs
//
//  Created by 周莹 on 15/12/15.
//  Copyright © 2015年 周莹. All rights reserved.
//

#import "MyViewController.h"
#import "PopoverView.h"
#import "MYTableViewCell.h"
#import "MoneryViewController.h"
#import "statisticalViewController.h"
#import "DetilViewController.h"
#import "SetViewController.h"
#import "OpnieViewController.h"
#import "TSPopoverController.h"
#import "TSActionSheet.h"

@interface MyViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *mianTableView;

@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.mianTableView.dataSource = self;
    self.mianTableView.delegate = self;
    
    self.title = @"玩坏广告";
    
    
//    UIBarButtonItem * topRightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showActionSheet:forEvent:)];
//    topRightButton.title = @"类别";
//    self.navigationItem.rightBarButtonItem = topRightButton;
//    self.navigationController.toolbarHidden = NO;

    
    
    UIButton *rightB = [UIButton buttonWithType:UIButtonTypeCustom];
    rightB.titleLabel.text = @"我";
    rightB.frame = CGRectMake(0, 0, 30, 30);
    [rightB setBackgroundImage:[UIImage imageNamed:LeftB] forState:UIControlStateNormal];
    [rightB addTarget:self action:@selector(showActionSheet:forEvent:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightB];
    
    // 注册Cell
    
    
    
    
    // Do any additional setup after loading the view from its nib.
}


-(void) showActionSheet:(id)sender forEvent:(UIEvent*)event
{
    
    
    TSActionSheet *actionSheet = [[TSActionSheet alloc] initWithTitle:@"类别"];
    
    [actionSheet addButtonWithTitle:@"分享" block:^{
        //        EmpViewController  *e = [[EmpViewController  alloc] init];
        //        [self.navigationController  pushViewController:e  animated:YES];
    }];
    [actionSheet addButtonWithTitle:@"扫一扫" block:^{
        //        FacViewController  *n = [[FacViewController  alloc] init];
        //        [self.navigationController  pushViewController:n animated:YES];
    }];
    [actionSheet addButtonWithTitle:@"帮助" block:^{
        //        PdViewController  *p = [[PdViewController  alloc] init];
        //        [self.navigationController  pushViewController:p  animated:YES];
    }];
    
    [actionSheet addButtonWithTitle:@"反馈de" block:^{
        //        PdViewController  *p = [[PdViewController  alloc] init];
        //        [self.navigationController  pushViewController:p  animated:YES];
    }];
    actionSheet.cornerRadius = 5;
    
    [actionSheet showWithTouch:event];
    
    
    
    
}





-(void)leftBDidPOP{
    
    CGPoint point = CGPointMake(self.view.frame.size.height, self.view.frame.size.width/5);
    NSArray *titles = @[@"分享", @"扫一扫", @"帮助",@"反馈"];
    PopoverView *pop = [[PopoverView alloc] initWithPoint:point titles:titles images:nil];
    pop.selectRowAtIndex = ^(NSInteger index){
        NSLog(@"select index:%ld", (long)index);
    };
    [pop show];
    
    
    
}

-(void)rightBDidPOP{


}



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 6;

}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *cell_id =@"flag";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cell_id];
    if (cell == nil) {
        //创建cell,不能少....
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cell_id];
        //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
       
        
    }
    if (indexPath.row == 1) {
        cell.textLabel.text = @"奖金钱包";
        cell.imageView.image = [UIImage imageNamed:@"qianbao"];
        
    }else if (indexPath.row == 2){
        cell.textLabel.text = @"游戏统计";
        cell.imageView.image = [UIImage imageNamed:@"tongji"];

    
    }else if (indexPath.row == 3){
    
        cell.textLabel.text = @"基础设置";
        cell.imageView.image = [UIImage imageNamed:@"qianbao"];
    
    }else if (indexPath.row == 4){
        
        cell.textLabel.text = @"意见反馈";
        cell.imageView.image = [UIImage imageNamed:@"fankui"];
        
    }else if (indexPath.row == 5){
        
        cell.textLabel.text = @"软件信息";
        cell.imageView.image = [UIImage imageNamed:@"xinxi"];
        
    }
    
        return cell;

}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;

}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 1) {
         MoneryViewController  *moneryC = [[MoneryViewController  alloc] init];
        [self.navigationController  pushViewController:moneryC animated:YES];
    }else if (indexPath.row == 2){
    
        statisticalViewController  *moneryC = [[statisticalViewController  alloc] init];
        [self.navigationController  pushViewController:moneryC animated:YES];
    
    
    }else if (indexPath.row == 3){
        
        SetViewController  *moneryC = [[SetViewController  alloc] init];
        [self.navigationController  pushViewController:moneryC animated:YES];
        
        
    }else if (indexPath.row == 4){
        
        OpnieViewController  *moneryC = [[OpnieViewController  alloc] init];
        [self.navigationController  pushViewController:moneryC animated:YES];
        
        
    }else if (indexPath.row == 5){
        
        DetilViewController  *moneryC = [[DetilViewController  alloc] init];
        [self.navigationController  pushViewController:moneryC animated:YES];
        
        
    }
   
}











- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
